﻿#region Usings

using System.Data.Entity;

#endregion

namespace DbConvertor.Dao.Config
{
    public class DbInitializer : CreateDatabaseIfNotExists<RailnetContext>
    {
        protected override void Seed(RailnetContext context)
        {
            context.Database.ExecuteSqlCommand("CREATE UNIQUE INDEX IX_Ru_Code ON Rus (Code)");
            
            context.Database.ExecuteSqlCommand("CREATE UNIQUE INDEX IX_Station_Eva ON Stations (Eva)");
            context.Database.ExecuteSqlCommand("CREATE INDEX IX_Station_Tisp ON Stations (Tisp)");
            context.Database.ExecuteSqlCommand("CREATE INDEX IX_Station_Epa ON Stations (Epa)");
            context.Database.ExecuteSqlCommand("CREATE INDEX IX_Station_IsBorder ON Stations (IsBorder)");
            context.Database.ExecuteSqlCommand("CREATE INDEX IX_Station_ForSale ON Stations (ForSale)");

            context.Database.ExecuteSqlCommand("CREATE UNIQUE INDEX IX_Relation_RelationNumber ON Relations (RelationNumber)");
            context.Database.ExecuteSqlCommand("CREATE INDEX IX_Relation_ValidFrom ON Relations (ValidFrom)");
            context.Database.ExecuteSqlCommand("CREATE INDEX IX_Relation_ValidTo ON Relations (ValidTo)");

            context.Database.ExecuteSqlCommand("CREATE INDEX IX_RelationDescription_ValidFrom ON RelationDescriptions (ValidFrom)");
            context.Database.ExecuteSqlCommand("CREATE INDEX IX_RelationDescription_ValidTo ON RelationDescriptions (ValidTo)");

            context.Database.ExecuteSqlCommand("CREATE INDEX IX_PriceDistance_ZoneFrom ON PriceDistances (ZoneFrom)");
            context.Database.ExecuteSqlCommand("CREATE INDEX IX_PriceDistance_ZoneTo ON PriceDistances (ZoneTo)");
            context.Database.ExecuteSqlCommand("CREATE INDEX IX_PriceDistance_ValidFrom ON PriceDistances (ValidFrom)");
            context.Database.ExecuteSqlCommand("CREATE INDEX IX_PriceDistance_ValidTo ON PriceDistances (ValidTo)");

            context.Database.ExecuteSqlCommand("CREATE INDEX IX_PriceDomestic_SubRu ON PriceDomestics (SubRu)");
            context.Database.ExecuteSqlCommand("CREATE INDEX IX_PriceDomestic_ZoneFrom ON PriceDomestics (ZoneFrom)");
            context.Database.ExecuteSqlCommand("CREATE INDEX IX_PriceDomestic_ZoneTo ON PriceDomestics (ZoneTo)");
            context.Database.ExecuteSqlCommand("CREATE INDEX IX_PriceDomestic_ValidFrom ON PriceDomestics (ValidFrom)");
            context.Database.ExecuteSqlCommand("CREATE INDEX IX_PriceDomestic_ValidTo ON PriceDomestics (ValidTo)");

            context.Database.ExecuteSqlCommand("CREATE INDEX IX_PriceSerial_Serial ON PriceSerials (Serial)");
            context.Database.ExecuteSqlCommand("CREATE INDEX IX_PriceSerial_ValidFrom ON PriceSerials (ValidFrom)");
            context.Database.ExecuteSqlCommand("CREATE INDEX IX_PriceSerial_ValidTo ON PriceSerials (ValidTo)");

            context.Database.ExecuteSqlCommand("CREATE INDEX IX_Distance_TispTisp ON Distances (TispTisp)");
        }
    }
}